import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.SqlUpdate;

import javax.sql.DataSource;
import java.sql.Types;

/**
 * Created with IntelliJ IDEA.
 * User: ttq
 * Date: 13-8-8
 * Time: 下午2:45
 * To change this template use File | Settings | File Templates.
 */
public class UpdateCreditRating extends SqlUpdate {
    public UpdateCreditRating(DataSource dataSource) {
        setDataSource(dataSource);
        setSql("update customer set credit_rating = ? where id = ?");
        declareParameter(new SqlParameter(Types.NUMERIC));
        declareParameter(new SqlParameter(Types.NUMERIC));
        compile();
    }

    public int run(int id, int rating) {
        Object[] params = new Object[]{new Integer(rating), new Integer(id)};
        return update(params);
    }
}
